package com.coderdream.chapter15.facade.sample.pagemaker;

import java.io.FileWriter;
import java.io.IOException;
import java.util.Properties;

public class PageMaker {
	private PageMaker() {
	}

	public static void makeWelcomePage(String mailaddr, String filename) {
		try {
			Properties mailprop = Database.getProperties("maildata");
			String username = mailprop.getProperty(mailaddr);
			HtmlWriter hw = new HtmlWriter(new FileWriter(filename));
			hw.title("Welcome to " + username + "'s page!");
			hw.paragraph("歡迎來到" + username + "的網頁");
			hw.mailto(mailaddr, username);
			hw.close();
			System.out.println(filename + " is created for " + mailaddr + " ("
					+ username + ")");
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
